#include "CmdProcess.h"

CmdProcess::CmdProcess()
{
}

bool CmdProcess::RunCmd(QString commandStr){
    if(commandStr.isEmpty()){
        return false;
    }
    QProcess *mProcess = new QProcess();
    if(mProcess!=NULL){
        mProcess->start(commandStr);
        if(!mProcess->waitForStarted()){
            qWarning()<<"Process start error."<<endl;
            return false;
        }
        if(!mProcess->waitForFinished()){
            qWarning()<<"Process run error."<<endl;
            return false;
        }
        if(mProcess->exitCode()!=0){
            qWarning()<<"Process exit error."<<endl;
            return false;
        }
    }else{
        return false;
    }
    return true;
}
